package com.wnhz.work.yz.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wnhz.work.yz.R;
import com.wnhz.work.yz.activity.FormManagerActivity;
import com.wnhz.work.yz.bean.FormListBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by admin on 2017/4/24.
 */
public class FormManagerAdapter extends BaseAdapter {
    private List<FormListBean.InfoEntity> addrList = new ArrayList<>();
    private FormManagerActivity formManagerActivity;

    public FormManagerAdapter(FormManagerActivity formManagerActivity, List<FormListBean.InfoEntity> addrList) {
        this.addrList = addrList;
        this.formManagerActivity = formManagerActivity;
    }

    @Override
    public int getCount() {
        return addrList.size();
    }

    @Override
    public Object getItem(int position) {
        return addrList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyHolder holder;
        if (convertView == null) {
            convertView = View.inflate(formManagerActivity, R.layout.item_form, null);
            holder = new MyHolder();
            holder.title = (TextView) convertView.findViewById(R.id.title);
            holder.content2 = (TextView) convertView.findViewById(R.id.content2);
            holder.content1 = (TextView) convertView.findViewById(R.id.content1);
            //
            convertView.setTag(holder);
        } else {
            holder = (MyHolder) convertView.getTag();
        }
        holder.title.setText("发票类型：" + addrList.get(position).getType_name());
        holder.content2.setText("发票抬头：" + addrList.get(position).getInvoice_title());
        holder.content1.setText(addrList.get(position).getInvoice_company());

        return convertView;
    }

    class MyHolder {
        TextView title, content1, content2;
    }


}
